home *** CD-ROM | disk | FTP | other *** search
- *
- * example.asm
- *
- *
-
- *** set editors tab to 8
-
-
- incdir 'includes:'
- include 'lvo.i' ; libbase-offsets
-
-
- EORKEY EQU $98
- FL_CODED EQU 0 ; bit 0
-
-
-
- Main: lea doslibname,a1
- moveq #0,d0
- move.l $4.w,a6
- jsr _LVOOpenLibrary(a6) ; doslib öffnen
- tst.l d0
- bne.s 0$
- rts
- 0$: move.l d0,dosbase
- move.l dosbase,a6
- jsr _LVOOutPut(a6) ; Ausgabe herstellen
- move.l d0,Handle
-
- move.l STF,a0
- bsr TextOffsetsToPtrs ; Textzeiger erstellen
-
- move.l STF,a0
- lea Passwort,a1
- move.l #1,d0
- bsr GetTextSeg ; TextSeg 1 -> d0
-
- move.l d0,a0
- moveq #0,d3
- 1$: addq.l #1,d3 ; strlen(TextSeg)
- tst.b (a0)+
- bne.s 1$
- subq.l #1,d3 ; d3 = strlen
- move.l d0,d2 ; d2 = TextSegment
- move.l handle,d1 ; d1 = FileHandle
- move.l dosbase,a6
- jsr _LVOWrite(a6) ; TextSeg ausgeben
- move.l dosbase,a1
- move.l $4.w,a6
- jsr _LVOCloseLibrary(a6) ; doslib schließen
- moveq #0,d0
- rts
-
-
-
- ********** SUBROUTINES *************
-
-
-
- *
- * GetTextSeg (d0,a0,a1) (Segment,Base,Password)
- *
- * Funktion: Segmentzeiger nach d0 holen
- *
- GetTextSeg:
- cmp.l 4(a0),d0
- bgt.s GTFail
- move.l 8(a0),d1
- btst.l #FL_CODED,d1 ; sein alles Seg. kodiert?
- beq.s 0$ ; wenn nein, zu ...
- movem.l d0/a0,-(sp)
- bsr DecodeTextSeg ; dekodiere Segment
- movem.l (sp)+,d0/a0
- 0$: lea 16(a0),a0
- subq.l #1,d0
- lsl.l #2,d0
- add.l d0,a0
- move.l (a0),d0 ; Segment-Ptr nach d0
- rts
- GTFail: moveq #0,d0
- rts
-
- *
- * TextOffsetsToPtrs (a0) (Base)
- *
- * Funktion: Alle belegten Slots mit Zeigern belegen
- *
- TextOffsetsToPtrs:
- move.l a0,d1
- move.l 4(a0),d0
- lea 16(a0),a0
- 1$: tst.l (a0)
- beq.s 2$
- add.l d1,(a0)+
- 2$: subq.l #1,d0
- bne.s 1$
- rts
-
-
- *
- * DecodeTextSeg (d0,a0,a1,d0) (Segment,Base,Password)
- *
- * d0 <- 0=Fehler
- *
- * verändert d0/d1/a0/a1
- *
- * Funktion: dekodieren eines Segments
- *
- DecodeTextSeg:
- movem.l d2/d3,-(sp)
- cmp.l 4(a0),d0
- bgt.s 3$ ; fehler: Segment-Nummer zu groß
- subq.l #1,d0
- lea 16(a0),a0 ; *1. Offset nach a0
- lsl.l #2,d0
- add.l d0,a0
- move.l (a0),a0
- cmp.l #0,a0
- bne.s 1$
- moveq #0,d0 ; fehler: Offset existiert nicht
- bra.s 3$
- 1$: moveq #0,d1 ; reset Password
- 2$: tst.b 1(a1,d1.w)
- beq.s 1$
- move.b (a1,d1.w),d2
- addq.l #1,d1
- move.b (a0),d3 ; nächstes Byte holen
- subq.b #1,d3
- eor.b #EORKEY,d3
- add.b d2,d3
- move.b d3,(a0)
- tst.b (a0)+ ; letztes Byte?
- bne.s 2$ ; nein, weiter
- move.l #-1,d0
- 3$: movem.l (sp)+,d2/d3
- rts
-
-
- ************ DATA **************
-
-
- handle: DC.L 0
-
- dosbase:
- DC.L 0
-
- doslibname:
- DC.B 'dos.library',0
-
- passwort:
- DC.B 'Mr. Spock Lives On Vulcan',0
-
- STF: DC.L daten
-
- daten: incbin ':segtextmaster/examples/example-text.stf'
-
-